/**
 * TODO: because of SN, currently based on jQuery < 1.5
 * @see http://wiki.apache.org/solr/SolJSON#JSON_specific_parameters
 * @class Manager
 * @augments AjaxSolr.AbstractManager
 */
AjaxSolr.Manager = AjaxSolr.AbstractManager.extend(
  /** @lends AjaxSolr.Manager.prototype */
  {
  executeRequest: function (servlet) {
	  var self = this;
	  self.beforeRequest();
	  if (this.proxyUrl) {
		  // jQuery.post(this.proxyUrl, { query: this.store.string() }, function (data) { self.handleResponse(data); }, 'json');
		  jQuery.ajax({url: this.proxyUrl, 
			  type: 'POST',
			  data: { query: this.store.string() },
			  dataType: 'json',
			  success: function (data) { 
				  self.handleResponse(data); 
			  },
			  error: function(xhr, textStatus, errorMsg) { 
				  self.onError(xhr, textStatus, errorMsg); 
			  },
			  complete: function(xhr, textStatus) { 
				  self.afterRequest();
			  }
		  });
	  } else {
		  //jQuery.getJSON(this.solrUrl + servlet + '?' + this.store.string() + '&wt=json&json.wrf=?', {}, function (data) { self.handleResponse(data); });
		  jQuery.ajax   ({ url: this.solrUrl + servlet + '?' + this.store.string() + '&wt=json&json.wrf=?', 
			  type: 'GET',
			  data: {},
			  dataType: 'json',
			  success: function (data) { 
				  self.handleResponse(data); 
			  },
			  error: function(xhr, textStatus, errorMsg) { 
				  self.onError(xhr, textStatus, errorMsg); 
			  },
			  complete: function(xhr, textStatus) { 
				  // a status of 2xx is a success.
				  self.afterRequest((xhr.status / 100) === 2);
			  }
		  });
		  
      }
  },
  onError: function(xhr, textStatus, errorMsg) {
	  // console.log("ERROR:    " + textStatus + " :: " + errorMsg);
  },
  beforeRequest: function() {
	  // console.log("before");
  },
  afterRequest: function(success) {
	  // console.log("after");  
  }
});
